{include file="public/header" /}

<style>
.layui-table-cell {

}
.cates .tr{display:none}
.cates .tr.p_0{display:table-row}
.cates span{    cursor: pointer;
    font-size: 24px;
    }
	
.icon-plus:before {
    content: "\f067";
}
.icon-minus:before {
    content: "\f068";
}
[class*='icon-']:before {
	display: inline-block;
	font-family: "FontAwesome";
	font-weight: normal;
	font-style: normal;
	vertical-align: baseline;
	line-height: 1;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}
</style>
<link rel="stylesheet" type="text/css" href="/static/admin/css/layui.css">
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>省份列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
					<div  class="col-sm-2" style="width: 100px">
						<div class="input-group" >  
							<a href="{:url('edit')}"><button class="btn btn-outline btn-primary" type="button">添加</button></a> 
						</div>
					</div>                        
                </div>
            </div>
            <!--搜索框结束-->
			
			

			<div class="layui-table-box" style="overflow: auto;height:calc(100% - 58px)">
				<table id="layui-table" cellspacing="0" cellpadding="0" border="0" class="layui-table cates"  style="height:100%;text-align:center;margin-bottom: 50px">
					<tr>
						<th style="text-align:left;font-weight:600;">名称</th>
						<th style="text-align:center;font-weight:600;">操作</th>
					</tr>
					{volist name="tree_list" id="vo"}
					<tr class="p_{$vo['parent_id']} tr">
					   <td class="title" data-id="{$vo['id']}" style="text-align:left;cursor: pointer;">
						{for start='0' end='$vo["level"]'}&nbsp;&nbsp;&nbsp;&nbsp;{/for}{if condition="$vo['is_have_sub'] eq 1"}<span class="icon-plus" data-id="{$vo['id']}">+</span>{/if}|--{$vo['title']}</td>
						<td>
							<a class="btn btn-primary btn-outline btn-xs" onclick="EditTag({$vo['id']})">编辑</a>
							<a class="btn btn-danger btn-outline btn-xs" onclick="DelTag({$vo['id']})">删除</a>
						</td>
					</tr>
						
					{/volist}
				</table>
			</div>

 </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

<!-- 加载动画 -->
<div class="spiner-example">
    <div class="sk-spinner sk-spinner-three-bounce">
        <div class="sk-bounce1"></div>
        <div class="sk-bounce2"></div>
        <div class="sk-bounce3"></div>
    </div>
</div>

{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/js/layui.js"></script>
<script type="text/javascript">
    
	//编辑
    function EditTag(id){
        location.href = '/admin/area/edit/id/'+id+'.html';
    }

    //删除
    function DelTag(id){
        lunhui.confirm(id,'{:url('del')}');
    }
	
	//$(".cates span.show").click(function(){
	$("body").delegate(".cates span.icon-plus","click", function(){
		var id = $(this).data('id');
		$(".cates .tr.p_"+id).show();
		$(this).removeClass('icon-plus');
		$(this).addClass('icon-minus');
		$(this).html('-');
	})
	
	//$(".cates span.hide").click(function(){
	$("body").delegate(".cates span.icon-minus","click", function(){
		var id = $(this).data('id');
		$(".cates .tr.p_"+id).hide();
		$.get("{:url('/admin/area/get_all_childid')}",{id:id},function(e){
			if(e){
				for(var i=0;i<e.length;i++){
					$(".cates .tr.p_"+e[i]).hide();
					$(".cates .tr.p_"+e[i]).find('span').removeClass('icon-minus');
					$(".cates .tr.p_"+e[i]).find('span').addClass('icon-plus').html('+');
					
				}
			}
		})
		$(this).removeClass('icon-minus');
		$(this).addClass('icon-plus');
		$(".cates .tr.p_"+id).find('span').removeClass('icon-minus');
		$(".cates .tr.p_"+id).find('span').addClass('icon-plus').html('+');
		$(this).html('+');
	})
</script>
</body>
</html>